package com.A21.Adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.A21MobileSales.R;

public class MainMenuListAdapter extends BaseAdapter   {      
    ViewHolder holder;
    LayoutInflater inflater;
    ArrayList<String> AryCustomerList;
    static final String KEY_CODE = "CustomerCode"; 
    static final String KEY_DESCRIPTION = "CustomerDescription";
    private Context context;
    public MainMenuListAdapter() {
		// TODO Auto-generated constructor stub
	} 
	public MainMenuListAdapter(Context _context,ArrayList<String> map) {  
		Activity act = (Activity) _context;
		this.context=_context;
		this.AryCustomerList = map;  
		inflater = (LayoutInflater) act
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
    
     
    public int getCount() {  
        return AryCustomerList.size();  
    }  
    public Object getItem(int arg0) {  
        return AryCustomerList.get(arg0);  
    }  
    public long getItemId(int arg0) {  
        return 0;  
    }  
       
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
		  View vi=convertView;
	      if(convertView==null){ 
	         vi = inflater.inflate(R.layout.row_home_screen, null);
	         holder = new ViewHolder();
	         holder.txtDescription = (TextView)vi.findViewById(R.id.HSLT_txtContent);
	        vi.setTag(holder);
	      }
	      else{ 
	    	holder = (ViewHolder)vi.getTag();
	       } 
	      try
	      {
	    	  holder.txtDescription.setText(AryCustomerList.get(position)); 
	      }
	      catch(Exception ex)
	      {
	    	  ex.printStackTrace();
	      }
	          
	     
	      return vi;
	}
  
   
    
    
    private class ViewHolder {
    	   TextView txtCode;
    	   TextView txtDescription;
    	  }
        
} 